﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">
	<!-- jsp文件头和头部 -->
	<%@ include file="../../system/main/main_top.jsp"%> 
	<link rel="stylesheet" media="screen" type="text/css" href="static/select2-js/select2.css" />
	</head> 
<body>
<div class="container-fluid" id="main-container">
<div id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="icon-home"></i> <a>订单管理</a> <span class="divider">
				<i class="icon-angle-right"></i>
		</span></li>
		<li class="active">礼品兑换</li>
	</ul>
	<!--.breadcrumb-->
</div>
<div id="page-content" class="clearfix">
  <div class="row-fluid">
	<div class="row-fluid">
			<!-- 检索  -->
			<form action="gift/exchange/list.do" method="post" name="giftExchangeForm" id="giftExchangeForm">
			<input type="hidden" name="org_id" id="org_id" value="${pageData.org_id }"/>
			<table>
				<tr>
					<td style="vertical-align:top;">
						<input type="text" id="order_no" name="order_no" value="${pageData.order_no }" placeholder="这里输入兑换码" />
					</td>
					<td><input class="span10 date-picker" id="lastStart" name="lastStart" value="${pageData.lastStartShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="兑换时间从"/></td>
					<td><input class="span10 date-picker" id="lastEnd" name="lastEnd" value="${pageData.lastEndShow}" type="text" data-date-format="yyyy-mm-dd" readonly="readonly" style="width:120px;" placeholder="兑换时间至"/></td>
					<td><form:select path="dictionary.dicvalue" items="${dictionaryList}" itemLabel="diccode" itemValue="dicvalue" title="礼单状态" style="width:100px; font-size:12px;"/></td>
					<td style="vertical-align:top;"><button class="btn btn-mini btn-light" onclick="search();"><i id="nav-search-icon" class="icon-search"></i></button></td>
					<td style="vertical-align:top;"><a class="btn btn-mini btn-light" onclick="clearCondition();" title="清空查询条件"><i id="nav-search-icon"></i>清空查询条件</a></td>
				</tr>
			</table>
			<!-- 检索  -->
		
			<table id="table_report" class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th>序号</th>
						<th>兑换码</th>
						<th>礼品编号</th>
						<th>礼品名称</th>
						<th>兑换积分</th>
						<th>兑换数量</th>
						<th>联系电话</th>
						<th>会员昵称</th>
						<th>兑换时间</th>
						<th>兑换状态</th>
						<th>兑换方式</th>
						<th>操作员</th>
						<th>操作时间</th>
						<th class="center">操作</th>
					</tr>
				</thead>
										
				<tbody>
				<!-- 开始循环 -->	
				<c:choose>
					<c:when test="${not empty varList}">
						<c:forEach items="${varList}" var="var" varStatus="vs">
							<tr>
								<td class='center' style="width: 30px;">${vs.index+1}</td>
								<td>${var.order_no}</td>
								<td>${var.gift_id }</td>
								<td>${var.gift_id_name }</td>
								<td>${var.total_ex_rose_mun }</td>
								<td>${var.quantity }</td>
								<td>${var.contact_mobile }</td>
								<td>${var.m_id_name }</td>
								<td><fmt:formatDate value="${var.create_time }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								<td>${var.status_name }</td>
								<td>${var.exchange_way_name }</td>
								<td>${var.operator_name }</td>
								<td><fmt:formatDate value="${var.operate_time }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
								<td style="width: 60px;" class="center">
									<div class='hidden-phone visible-desktop btn-group'>
										<a class='btn btn-mini btn-info' title="查看" onclick="view('${var.exchange_id }');"><i class='icon-eye-open'></i></a>
										&nbsp;&nbsp;
										<c:if test="${var.status != 3}">
											<a class='btn btn-mini btn-info' title="编辑" onclick="edit('${var.exchange_id }');">兑换礼品</a>
										</c:if>
									</div>
								</td>
							</tr>
						</c:forEach>
						
						<!-- <tr>
							<td colspan="100" class="center">您无权查看</td>
						</tr> -->
					</c:when>
					<c:otherwise>
						<tr class="main_info">
							<td colspan="100" class="center" >没有相关数据</td>
						</tr>
					</c:otherwise>
				</c:choose>
				</tbody>
			</table>
			
			<div class="page-header position-relative">
				<table style="width:100%;">
					<tr>
						<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
					</tr>
				</table>
			</div>
		</form>
	</div>
	<!-- PAGE CONTENT ENDS HERE -->
  </div><!--/row-->
	
</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<script type="text/javascript" src="static/select2-js/select2.js"></script>
		<script type="text/javascript" src="static/select2-js/select2.min.js"></script>
		<script type="text/javascript" src="static/select2-js/select2_locale_zh-CN.js"></script>
		<!-- 引入 -->
		
		<script type="text/javascript">
		$(top.hangge());
		
		//检索
		function search(){
			$("#giftExchangeForm").submit();
		}
		
		function view(exchange_id){
			top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="查看详情";
			 diag.URL = '<%=basePath%>gift/exchange/goViewGiftExchange.do?exchange_id='+exchange_id;
			 diag.Width = 600;
			 diag.Height = 550;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//修改
		function edit(exchange_id){
			top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="兑换礼品";
			 diag.URL = '<%=basePath%>gift/exchange/goEditGiftExchange.do?exchange_id='+exchange_id;
			 diag.Width = 800;
			 diag.Height = 650;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					 nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		function clearCondition(){
			$("#nav-search-input").val("");
			$("#nav-search-input2").val("");
			$("#lastStart").val("");
			$("#lastEnd").val("");
		}
		
		// 导游
		$("#order_no").select2({
			placeholder : "请输入订单号",
			minimumInputLength : 1,
			width : 220,
			allowClear : true,
			ajax : { // instead of writing the function to execute the
						// request we use Select2's convenient helper
				url : "<%=basePath%>gift/exchange/orderno-list.do",
				dataType : 'text',
				data : function(order_no, page) {
					return {
						order_no : order_no
					// search term
					};
				},
				results : function(data, page) { // parse the results
													// into the format
													// expected by Select2.
					// since we are using custom formatting functions we do
					// not need to alter remote JSON data
					return {
						results : data
					};
				}
			},
			initSelection : function(element, callback) {
				var value = element.val();
				var idx = value.indexOf("-");
				var text = '';
				if (idx != -1) {
					text = value.substring(idx + 1);
				}
				var data = {
					id : element.val(),
					text : text
				};
				callback(data);
			},
			formatResult : movieFormatResult, // omitted for brevity, see
												// the source of this page
			// formatSelection: movieFormatSelection, // omitted for
			// brevity, see the source of this page
			dropdownCssClass : "bigdrop", // apply css that makes the
											// dropdown taller
			escapeMarkup : function(m) {
				return m;
			} // we do not want to escape markup since we are displaying
				// html in results
		});
		
		function movieFormatResult(result, container, query, escapeMarkup) {
			return result.text;
		}
		</script>
		<script type="text/javascript">
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			//日期框
			$('.date-picker').datepicker();
		});
		</script>
	</body>
</html>

